﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RRTlnkoolitoetusparingkRequest", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RRTlnkoolitoetusparingkRequest))]
    public class RRTlnkoolitoetusparingkRequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRRTlnkoolitoetusparingkRequest clazz;
        
        public RRTlnkoolitoetusparingkRequestSerializer(IRRTlnkoolitoetusparingkRequest clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("pocSalvestaNuppKuva");
            if (clazz.PocSalvestaNuppKuva!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocSalvestaNuppKuva))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocSalvestaNuppKuva");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picLapseIsikukood");
            if (clazz.PicLapseIsikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicLapseIsikukood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicLapseIsikukood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picKontaktaadress");
            if (clazz.PicKontaktaadress!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicKontaktaadress))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicKontaktaadress");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picTelefon");
            if (clazz.PicTelefon!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicTelefon))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicTelefon");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picSaajaEesnimi");
            if (clazz.PicSaajaEesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicSaajaEesnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicSaajaEesnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picSaajaPerenimi");
            if (clazz.PicSaajaPerenimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicSaajaPerenimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicSaajaPerenimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picSaajaIsikukood");
            if (clazz.PicSaajaIsikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicSaajaIsikukood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicSaajaIsikukood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picSaajaKonto");
            if (clazz.PicSaajaKonto!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicSaajaKonto))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicSaajaKonto");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="pocSalvestaNuppKuva") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnkoolitoetusparingkRequest>pocSalvestaNuppKuva");
                }
                clazz.PocSalvestaNuppKuva = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocSalvestaNuppKuva")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnkoolitoetusparingkRequest>pocSalvestaNuppKuva", Reader.LocalName);
            }
            if (Reader.LocalName=="picLapseIsikukood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnkoolitoetusparingkRequest>picLapseIsikukood");
                }
                clazz.PicLapseIsikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picLapseIsikukood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnkoolitoetusparingkRequest>picLapseIsikukood", Reader.LocalName);
            }
            if (Reader.LocalName=="picKontaktaadress") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnkoolitoetusparingkRequest>picKontaktaadress");
                }
                clazz.PicKontaktaadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picKontaktaadress")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnkoolitoetusparingkRequest>picKontaktaadress", Reader.LocalName);
            }
            if (Reader.LocalName=="picTelefon") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnkoolitoetusparingkRequest>picTelefon");
                }
                clazz.PicTelefon = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picTelefon")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnkoolitoetusparingkRequest>picTelefon", Reader.LocalName);
            }
            if (Reader.LocalName=="picSaajaEesnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnkoolitoetusparingkRequest>picSaajaEesnimi");
                }
                clazz.PicSaajaEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picSaajaEesnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnkoolitoetusparingkRequest>picSaajaEesnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="picSaajaPerenimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnkoolitoetusparingkRequest>picSaajaPerenimi");
                }
                clazz.PicSaajaPerenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picSaajaPerenimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnkoolitoetusparingkRequest>picSaajaPerenimi", Reader.LocalName);
            }
            if (Reader.LocalName=="picSaajaIsikukood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnkoolitoetusparingkRequest>picSaajaIsikukood");
                }
                clazz.PicSaajaIsikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picSaajaIsikukood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnkoolitoetusparingkRequest>picSaajaIsikukood", Reader.LocalName);
            }
            if (Reader.LocalName=="picSaajaKonto") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnkoolitoetusparingkRequest>picSaajaKonto");
                }
                clazz.PicSaajaKonto = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picSaajaKonto")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnkoolitoetusparingkRequest>picSaajaKonto", Reader.LocalName);
            }
        }
    }
}
